<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            padding-bottom: 800px;
            padding-left: 30px;
        }
        ul{
            list-style: none;
            padding: 0px 0px;
            margin: 0px;
            width: 400px;
            border: 1px solid #999;
            margin-bottom: 20px;
        }
        ul li{
            padding: 8px 16px;
            display: flex;
            flex-flow: row nowrap;
            justify-content: space-between;
        }
        ul li:not(:last-child){
            border-bottom: 1px solid #999;
            
        }
        .switch{
            font-size: 36px;
            /* 该样式内部的所有元素大小单位统一使用 em 单位 */
            cursor: pointer;
            user-select: none;
        }
        .text{
            transition:all 150ms ease;
            vertical-align: middle;
        }
        .text.active{
            color: #409eff;
        }
        .pot{
            display: inline-block;
            width: 3em;
            height: 1.5em;
            background-color: #dcdfe6;
            vertical-align: middle;
            margin: 0px 0.4em;
            border-radius:3em;
            transition:all 150ms ease;
            box-shadow: 0 0 0.2em #b1b1b1 inset;
        }
        .pot i{
            display: inline-block;
            width: 1.5em;
            height: 1.5em;
            background-color: white;
            border-radius: 50%;
            transform: scale(0.8);
            transition:all 150ms ease-out;
            box-shadow: 0 0 0.2em #b1b1b1;
        }
        .event{
            display: none;
        }
        .event:checked + .pot{
            background-color: #409eff;
            box-shadow: 0 0 0.2em #2f75bb inset;
        }
        .event:checked + .pot i{
            transform: translate(100%,0) scale(0.8);
            box-shadow: 0 0 0.2em #2f75bb;
        }
    </style>
</head>
<body>
    <div id="app">
        <h4>权限控制</h4>
        <!-- <ul>
            <li v-for="item in list">
                <span>{{ item }}</span>
                <input type="checkbox" name="" id="">
            </li>
        </ul> -->
        <ul>
            <li v-for="item in list">
                <span>{{ item }}</span>
                <!-- <label class="switch" style="font-size: 12px;">
                    <input class="event" type="checkbox">
                    <span class="pot">
                        <i></i>
                    </span>
                </label> -->
                <switch-btn></switch-btn>
            </li>
        </ul>
        <h4>功能控制</h4>
        <ul>
            <li v-for="item in list2">
                <span>{{ item }}</span>
                <!-- <label class="switch" style="font-size: 12px;">
                    <input class="event" type="checkbox">
                    <span class="pot">
                        <i></i>
                    </span>
                </label> -->
                <switch-btn></switch-btn>
            </li>
        </ul>
    </div>
    <script type="module">
        // 加载 Vue3 的ESM 模块文件
        import { createApp } from "../assets/vue3/vue.esm-browser.js"

        const switchOptions = {
            template:`
                <label class="switch" style="font-size: 12px;">
                    <input class="event" type="checkbox">
                    <span class="pot">
                        <i></i>
                    </span>
                </label>
            `,
        }

        createApp({
            data(){
                return {
                    list:[
                        "允许访问话筒",
                        "允许访问摄像头",
                        "允许访问相册",
                        "允许访问地址"
                    ],
                    list2:[
                        "开启闹钟",
                        "开启视频",
                        "开启蓝牙",
                        "开启定位"
                    ]
                }
            },
            components: {
                // key 组件名(自定义标签名)
                // value 组件对应的相关配置(配置等同于createVNode的配置)
                "switch-btn":switchOptions
            },
        }).mount("#app")
    </script>
</body>
</html>